Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payouts: Show bank reference key on payout details page #9886

Closed
wants to merge 31 commits into from

Conversation

nagpai
Copy link
Contributor

@nagpai nagpai commented Dec 5, 2024

Fixes #9878

Changes proposed in this Pull Request

  • Show bank reference key of a payout on its details page, when it is available. The PR tentatively adds it to the top header. Depending on feedback from stakeholders we can have this shifted / modified. Screenshot of how it appears:

Note that in test payouts, the bank reference key is of 41 characters length. In real payouts, we see a variety of lengths, sometimes much smaller ( 12 characters ).

  • There is a copy button added too for easy copying by merchant.

  • The bank reference key shows as N/A if it is not available from Stripe.

  • The PR also adds a few CSS fixes for mobile view. This is needed to change the alignment of the summary items as column, and adjust borders + text alignment for smaller screens < 660px .

Testing instructions

  • Use a test account that preferably has payouts from before December 2, 2024, to test with payouts without the bank reference key. You may use acct_1OuYn1QpUShfetUA , if you like.
  • Checkout this branch on your client and run npm start to build assets.
  • Browse to Payments > Payouts
  • Click on any Payout where you see a Bank reference key
  • You should see the same key on the top, on the details page when it opens. Similar to the first screenshot above.
  • Click the Copy button beside the Bank reference key, and see that it copies the key to clipboard.
  • Back on the payouts list page, click on any payout without a bank reference key
  • You should not see the bank reference key mentioned on the header of the details page. Similar to the second screenshot above.
  • Test on mobile screen too

  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@botwoo
Copy link
Collaborator

botwoo commented Dec 5, 2024

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 9886 or branch name add/9878-bank-ref-key-payout-details in your-test.site/wp-admin/admin.php?page=jetpack-beta&plugin=woocommerce-payments

Option 2. Jurassic Ninja - available for logged-in A12s

🚀 Launch a JN site with this branch 🚀

ℹ️ Install this Tampermonkey script to get more options.


Build info:

  • Latest commit: 8a4f35e
  • Build time: 2024-12-13 07:42:45 UTC

Note: the build is updated when a new commit is pushed to this PR.

Copy link
Contributor

github-actions bot commented Dec 5, 2024

Size Change: +956 B (0%)

Total Size: 1.34 MB

Filename Size Change
release/woocommerce-payments/dist/index-rtl.css 53.1 kB +333 B (+1%)
release/woocommerce-payments/dist/index.css 53.1 kB +335 B (+1%)
release/woocommerce-payments/dist/index.js 303 kB +288 B (0%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.37 kB
release/woocommerce-payments/assets/css/admin.rtl.css 1.37 kB
release/woocommerce-payments/assets/css/success.css 182 B
release/woocommerce-payments/assets/css/success.rtl.css 184 B
release/woocommerce-payments/dist/blocks-checkout-rtl.css 2.63 kB
release/woocommerce-payments/dist/blocks-checkout.css 2.63 kB
release/woocommerce-payments/dist/blocks-checkout.js 54.7 kB
release/woocommerce-payments/dist/cart-block.js 17 kB
release/woocommerce-payments/dist/cart.js 5.73 kB
release/woocommerce-payments/dist/checkout-rtl.css 932 B
release/woocommerce-payments/dist/checkout.css 931 B
release/woocommerce-payments/dist/checkout.js 33.4 kB
release/woocommerce-payments/dist/express-checkout-rtl.css 229 B
release/woocommerce-payments/dist/express-checkout.css 229 B
release/woocommerce-payments/dist/express-checkout.js 15.1 kB
release/woocommerce-payments/dist/frontend-tracks.js 854 B
release/woocommerce-payments/dist/multi-currency-analytics.js 1.08 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 4.46 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.6 kB
release/woocommerce-payments/dist/multi-currency.css 4.46 kB
release/woocommerce-payments/dist/multi-currency.js 57.3 kB
release/woocommerce-payments/dist/order-rtl.css 730 B
release/woocommerce-payments/dist/order.css 730 B
release/woocommerce-payments/dist/order.js 42 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 1.32 kB
release/woocommerce-payments/dist/payment-gateways.css 1.32 kB
release/woocommerce-payments/dist/payment-gateways.js 38.4 kB
release/woocommerce-payments/dist/plugins-page-rtl.css 386 B
release/woocommerce-payments/dist/plugins-page.css 386 B
release/woocommerce-payments/dist/plugins-page.js 20.1 kB
release/woocommerce-payments/dist/product-details-rtl.css 433 B
release/woocommerce-payments/dist/product-details.css 436 B
release/woocommerce-payments/dist/product-details.js 12.3 kB
release/woocommerce-payments/dist/settings-rtl.css 11.6 kB
release/woocommerce-payments/dist/settings.css 11.5 kB
release/woocommerce-payments/dist/settings.js 224 kB
release/woocommerce-payments/dist/subscription-edit-page.js 703 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.2 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 730 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.3 kB
release/woocommerce-payments/dist/tokenized-express-checkout-rtl.css 229 B
release/woocommerce-payments/dist/tokenized-express-checkout.css 229 B
release/woocommerce-payments/dist/tokenized-express-checkout.js 15.8 kB
release/woocommerce-payments/dist/tos-rtl.css 235 B
release/woocommerce-payments/dist/tos.css 235 B
release/woocommerce-payments/dist/tos.js 21.8 kB
release/woocommerce-payments/dist/woopay-direct-checkout.js 6.13 kB
release/woocommerce-payments/dist/woopay-express-button.js 24.8 kB
release/woocommerce-payments/dist/woopay-rtl.css 4.31 kB
release/woocommerce-payments/dist/woopay.css 4.28 kB
release/woocommerce-payments/dist/woopay.js 71 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 625 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 814 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.46 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/jetpack-script-data.js 767 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/react-jsx-runtime.js 553 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.02 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/script-data.js 69 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/babel.config.js 163 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/identity-crisis.css 2.45 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/identity-crisis.js 14.2 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/identity-crisis.rtl.css 2.45 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.js 280 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.rtl.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.css 625 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.js 333 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.rtl.css 626 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-users.js 417 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 584 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.css 215 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.css 721 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.js 412 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-users.js 621 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.04 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-empty-state.css 294 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 408 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.59 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 301 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 746 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 574 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 414 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 543 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.4 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.78 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.84 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 545 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.52 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.7 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 507 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 358 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 428 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 782 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.09 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.26 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 391 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.04 kB

compressed-size-action

@aheckler
Copy link
Member

aheckler commented Dec 5, 2024

A thought: if a merchant's looking for a bank reference key for a particular payout, it's probably because they think that their payout is missing. They almost certainly plan on passing the reference key along to their bank so that their bank can trace it.

To help them with that, we could make a few adjustments:

  • Use a monospace font to disambiguate characters, e.g. l and I or 0 and O.
  • Add a "copy button" similar to test mode checkout (image below).

Screenshot taken on 2024-12-05 at 17 59 04 UTC@2x

The bank reference key line is not shown when it is not available for any reason

On the Payments > Payouts page, when the key is not available, we show N/A instead of just leaving that table cell empty. If you ask me, we should do the same on the payout detail page as well.

@nagpai
Copy link
Contributor Author

nagpai commented Dec 6, 2024

@aheckler - Those are great points!

I have removed the needs review tag for now and will add it back after i have worked on these feedback points.

@nagpai
Copy link
Contributor Author

nagpai commented Dec 6, 2024

Thanks for the great feedback points, @aheckler

Use a monospace font to disambiguate characters, e.g. l and I or 0 and O.

I checked and these characters look distinct. Here is a screenshot. I hope it is fine

Add a "copy button" similar to test mode checkout (image below).

On the Payments > Payouts page, when the key is not available, we show N/A instead of just leaving that table cell empty. If you ask me, we should do the same on the payout detail page as well.

I have implemented these via latest commits. These were very useful points, thanks!

@nagpai nagpai requested review from a team and removed request for a team December 6, 2024 13:26
@rogermattic
Copy link

Hwy @nagpai ! Thanks for working on this.

I agree with @aheckler's suggestions and am glad we’re adding such useful details to the payout page! I think it might be worth exploring if there’s a different way to arrange the details, as the heading section could potentially be improved. If that’s alright, I’ll take a look at it next week and get back to you.

The bank reference key shows as N/A if it is not available from Stripe.
Is there any reason that we could pass onto the users to say why this is not available?

@nagpai
Copy link
Contributor Author

nagpai commented Dec 6, 2024

What about lower case L and upper case I?

Eagle eye catch, @aheckler ! I also spotted that we use monospace in Transactions details page for the Payment ID!

I have changed it for the Bank Reference Id here - 292bfd9

image

@@ -70,7 +70,7 @@ interface SummaryItemProps {
label: string;
value: string | JSX.Element;
valueClass?: string | false;
detail?: string;
detail?: string | JSX.Element;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this align with the types for the component we are overriding (SummaryNumber from Woo core?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original SummaryItemNumber ( child within the summary list ) , does not have a detail prop. It was introduced in the customized SummaryListItem for the Deposit Overview header.

Copy link
Contributor

@haszari haszari Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but I think we should avoid inheriting/overriding components like this. We risk depending on implementation details, so our plugin is sensitive to changes in Woo core.

Ideally we'd either:

  • Use components from Woo/upstream as is, with no customisations or overrides.
  • Implement our own self-contained components, with no dependencies.

Copy link
Contributor

@haszari haszari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this yet – just a code review.

My main feedback is that the approach to DepositDateItem is convoluted, and I think we should be able to achieve what we need by making simple, self-contained components for each logical item in the header – either as SummaryItem, or a custom component similar to SummaryItem. Note also that SummaryItem (IMO) is not adding much value, it's just a wrapper for Woo core SummaryNumber; maybe we don't need it.

Related, the click-to-copy behaviour is nice, but not essential. If we can implement this without side effects, great; but if we have to use side effects it might not be worth it – high complexity for low benefit.

Some minor thoughts about the UI:

  • Bank reference key is long, and there's not much space to play with here (especially if keys are long). Is there a more compact label that would be just as clear to merchants?
  • N/A is loud in all caps. I'm not sure what we do elsewhere, but I'd lean toward n/a or just render not available since it is similar size to a real key, and immediately clear.

copyButton.classList.remove( 'state--copied' );
}, 2000 );
}
} );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we implement the copy button behaviour in a more React-idiomatic way, without using a side effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed this and used useEffect to track the state of the copy button click. Thanks for the guidance to align with the declarative way of doing things in React!

</>
) : (
'N/A'
) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make a custom component that encapsulates all this behaviour, e.g. PayoutBankDetails?

That component would take care of:

  • Rendering the bank account / payout destination (as before)
  • Rendering the bank ref, with a clickable button to copy
  • Handling the click on the bank ref & copying to clipboard
  • Setting state somewhere to show that the ref has been copied
  • Whatever is needed to look / behave like a SummaryNumber

Then, we could just render that component alongside all the others in the table header:

<SummaryList>
  <SummaryItem  />
  <SummaryItem  />
  <PayoutBankDetails />
</SummaryList>

Copy link
Contributor Author

@nagpai nagpai Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per discussion during our pair coding session:

  • If the component were to be built from scratch, it would be better to use a Card and add the design we need directly as a custom component here. The design requirement diverts quite a bit from the SummaryList + SummaryNumber / SummaryItem .
  • We will need to also check for behavior needed for conditional views like Instant Deposit and Withdrawals if we redesign
  • For the current PR the next best thing we could do is to move DepositDateItem as an independent component outside DepositOverview where it is currently nested in a complex way. This will make it simple, modular and more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haszari - We discussed adding a smooth transition during our pair coding session. We are currently using SVG as mask-image attribute on the same button. This attribute is not smooth animatable from what i checked. It is classified as discrete .

I checked a workaround of rendering separate icons and making them appear and disappear with transitions, but not sure if the added complexity was worth it. Hence have not indulged in the transition animation for now.

color: $dark-gray-500;

@include breakpoint( '<480px' ) {
word-wrap: break-word;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this useful at all screen sizes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup it is. Thanks for catching that. I will remove the media query.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - 8bda02c !

line-height: 36px;
text-align: left;
border-top: 1px solid $studio-gray-5;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we tweaking for smaller (<660px) screens? Should we make that behaviour the default, and progressively enhance on larger screens (i.e. mobile first)?

Copy link
Contributor Author

@nagpai nagpai Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are making the font size smaller, making it left aligned and adding a border on top.

The layout by itself - overall is desktop first. The columns have a sideways scroll. My gut feel is that merchants would mostly use a tablet or a laptop to check WP admin. Hence would prefer keeping it as-is, but open to revisiting that! The padding property within the media query is redundant though, removed it - 8bda02c.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are making the font size smaller, making it left aligned and adding a border on top.

Why? Ideally the style changes for smaller screens are minimal (so it's easy to maintain), this sounds like a lot! If you are adding different behaviour for different screen sizes I'd recommend including details in the PR description – I see you have a screenshot, but even better if you explain why the changes are needed.

Copy link
Contributor Author

@nagpai nagpai Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are adding different behaviour for different screen sizes I'd recommend including details in the PR description – I see you have a screenshot, but even better if you explain why the changes are needed.

I have added a note on why we are doing the CSS change, in the PR description

The PR also adds a few CSS fixes for mobile view. This is needed to change the alignment of the summary items as column, and adjust borders + text alignment for smaller screens < 660px .

@nagpai
Copy link
Contributor Author

nagpai commented Dec 9, 2024

@haszari - Related to the UI feedback:

Bank reference key is long, and there's not much space to play with here (especially if keys are long). Is there a more compact label that would be just as clear to merchants?

Just like for bank account / CC we show the last 4 digits, If we could ascertain the minimum number of characters sufficient to identify a payout at least at first glance. We could give the complete number as a tooltip or via copy.

N/A is loud in all caps. I'm not sure what we do elsewhere, but I'd lean toward n/a or just render not available since it is similar size to a real key, and immediately clear.

I actually picked it up from the reports available within WooCommerce core Analytics menu.

@haszari
Copy link
Contributor

haszari commented Dec 9, 2024

Bank reference key is long, and there's not much space to play with here (especially if keys are long). Is there a more compact label that would be just as clear to merchants?

Just like for bank account / CC we show the last 4 digits, If we could ascertain the minimum number of characters sufficient to identify a payout at least at first glance. We could give the complete number as a tooltip or via copy.

That's an interesting idea! Though would complicate the UI a little.

To be clear though, I was referring to the label not the value. The label Bank reference key (or Bank reference ID) is taking up a lot of space.

@haszari
Copy link
Contributor

haszari commented Dec 9, 2024

N/A is loud in all caps. I'm not sure what we do elsewhere, but I'd lean toward n/a or just render not available since it is similar size to a real key, and immediately clear.

I actually picked it up from the reports available within WooCommerce core Analytics menu.

Great - nice to see the consistency 🙌

@nagpai
Copy link
Contributor Author

nagpai commented Dec 11, 2024

@rogermattic has come back with some great design suggestions in the original issue linked to this PR. I am keeping the PR as In progress for now, since next steps would depend on what design changes we adopt.

Copy link
Contributor

@haszari haszari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rogermattic has come back with some #9878 (comment) in the original issue linked to this PR. I am keeping the PR as In progress for now, since next steps would depend on what design changes we adopt.

I think the new design is different enough it's worth closing this and starting a clean PR. If there is useful code in this PR, you can easily copy it over.

@@ -70,7 +70,7 @@ interface SummaryItemProps {
label: string;
value: string | JSX.Element;
valueClass?: string | false;
detail?: string;
detail?: string | JSX.Element;
Copy link
Contributor

@haszari haszari Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but I think we should avoid inheriting/overriding components like this. We risk depending on implementation details, so our plugin is sensitive to changes in Woo core.

Ideally we'd either:

  • Use components from Woo/upstream as is, with no customisations or overrides.
  • Implement our own self-contained components, with no dependencies.


if ( ! isCopied ) {
setIsCopied( true );
setTimeout( () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to take care with setTimeout in React. In particular, need to clean up the timeout on unmount. (I need a refresher on this myself).

This article looks reasonable, there may be better info out there (especially on React official docs): https://felixgerschau.com/react-hooks-settimeout/

Copy link
Contributor Author

@nagpai nagpai Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very helpful and a great concept I learned today! I have implemented it in the CopyButton component. I hope I have done it correctly. Would appreciate if you could check once 🙏🏼

onClick={ () => {
const bankReferenceId = document.querySelector(
'.woopayments-payout-bank-reference-id'
)?.textContent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we get the value without fishing around in the DOM (clue: deposit prop 😁)? We try to avoid that in React; the component should not depend on the DOM, it should be self contained.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome hint! I wonder how I missed it 😄

Tweaked it here - af176bd

&.state--copied i {
mask-image: url( 'assets/images/icons/check-green.svg?asset' );
background-color: $studio-green-50;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of css (and some React behaviour) for this little copy-to-clipboard button. Could we package it into a little component? The button is nicely general-purpose so is a good candidate for an abstraction.

Copy link
Contributor Author

@nagpai nagpai Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion! I have moved the button to a separate component via 0d26f76 and 5c3c6aa

This will be certainly useful with the new design. Once it is approved, I can also suggest it to be used in the checkout from where I originally borrowed :D

@nagpai
Copy link
Contributor Author

nagpai commented Dec 16, 2024

I am closing this PR in favor of #9945 .

I am working afresh on the new design recommendations to show bank reference ID in an uncluttered way. I have retained some useful work like the copy button component on the new PR.

@nagpai nagpai closed this Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Payouts: Show Bank Reference Key on Payout details page.
5 participants